package org.vacoor.xqq.core.bean;

import java.util.LinkedList;
import java.util.List;

/**
 * 联系人分组
 */
public class Category implements Comparable<Category> {
    private int index;      // 显示索引
    private String name;    // 名称
    private List<Contact> contacts = new LinkedList<Contact>();
    private int onlineCount = 0;

    public Category() {
    }

    public Category(int idx, String name) {
        setIndex(idx);
        setName(name);
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<Contact> getContacts() {
        return contacts;
    }

    public void setContacts(List<Contact> contacts) {
        this.contacts = contacts;
    }

    public int getOnlineCount() {
        return onlineCount;
    }

    public void setOnlineCount(int onlineCount) {
        this.onlineCount = onlineCount;
    }

    public int getTotalCount() {
        return contacts.size();
    }

    @Override
    public int compareTo(Category o) {
        if (this == o) {
            return 0;
        }
        if (o == null) {
            return -1;
        }

        if (this.getIndex() > o.getIndex()) {
            return 1;
        }
        return this.getIndex() == o.getIndex() ? 0 : -1;
    }

    @Override
    public String toString() {
        return this.getClass().getCanonicalName() + ": {" +
                "index:" + index +
                ", name:'" + name + '\'' +
                ", contacts:" + contacts +
                ", onlineCount:" + onlineCount +
                '}';
    }

}
